#include <iostream>

// Count the number of integers between [0, n] that ends with k.
static long long count(long long n, long long k)
{
    if (n < k)
        return 0;

    // Find the smallest 10's power greater than k.
    long long p = 10;
    while (p <= k)
        p = p * 10;

    return (n - k) / p + 1;
}

int main()
{
    int T;
    std::cin >> T;
    for (int t = 0; t < T; t++)
    {
        long long x, a, b;
        std::cin >> x >> a >> b;
        std::cout << count(b, x) - count(a-1, x) << std::endl;
    }
    return 0;
}
